package cn.outsourcing.supermarket.controller.backstage;

import cn.outsourcing.supermarket.common.Result;
import cn.outsourcing.supermarket.common.utils.ResultUtils;
import cn.outsourcing.supermarket.dto.OnlyIdPayloadDTO;
import cn.outsourcing.supermarket.dto.backstage.BackstageAdInfoDTO;
import cn.outsourcing.supermarket.dto.backstage.BackstageUpdateStatusDTO;
import cn.outsourcing.supermarket.service.HiolabsAdService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author gzkemays
 * @since 2021/11/5 2:48
 */
@RestController
@RequestMapping("/admin/ad")
public class AdController {
  @Resource HiolabsAdService adService;

  @GetMapping("/saleStatus")
  public Result saleStatus(BackstageUpdateStatusDTO dto) {
    return ResultUtils.simpleResult(adService.saleStatus(dto));
  }

  @GetMapping("/info")
  public Result saleStatus(OnlyIdPayloadDTO dto) {
    return ResultUtils.simpleResult(adService.info(dto));
  }

  @PostMapping("/store")
  public Result store(@RequestBody BackstageAdInfoDTO dto) {
    return ResultUtils.simpleResult(adService.store(dto));
  }

  @PostMapping("/getallrelate")
  public Result getAllRelate(@RequestBody OnlyIdPayloadDTO dto) {
    return ResultUtils.simpleResult(adService.getRelates());
  }

  @PostMapping("/destory")
  public Result destroy(@RequestBody OnlyIdPayloadDTO dto) {
    return ResultUtils.simpleResult(adService.destroyAd(dto));
  }
}
